package top.lshaci.framework.log.service.impl;

import lombok.extern.slf4j.Slf4j;
import top.lshaci.framework.log.enums.OperateStatus;
import top.lshaci.framework.log.model.LogModel;
import top.lshaci.framework.log.service.LogService;

/**
 * LoggingService
 *
 * @author lshaci
 * @since 1.0.9
 */
@Slf4j
public class LoggingService implements LogService {

    @Override
    public void record(LogModel model) {
        OperateStatus status = model.getStatus();
        Object content = model.getContent();
        if (OperateStatus.failure.equals(status)) {
            log.warn("Execution failure ==> {}:{} - Title: {}, Content: {}, Exception message: {}.", model.getTargetClass().getName(), model.getTargetMethod(), model.getTitle(), content, model.getExceptionMessage());
        } else if (OperateStatus.success.equals(status)) {
            log.debug("Execution success ==> {}:{} - Title: {}, Content: {}.", model.getTargetClass().getName(), model.getTargetMethod(), model.getTitle(), content);
        }
    }
}
